home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
music
/
188
/
c
/
doit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-10-14
|
911b
|
48 lines
#include <stdio.h>
#include "qsed.h"
static int lines=0;
static char work[BUFSIZ];
void doit(cmd,f)
COMMAND *cmd;
FILE *f;
{
int fix_lines;
#ifdef VERBOSE
fprintf(stderr,"starting line: %u\nending line %u\n command type %u\n",
cmd->start,cmd->end,cmd->type);
#endif
fix_lines=0;
if(cmd->type==COM_ERR)
fatal("error in command file");
while(lines < cmd->start)
{
fgets(work,BUFSIZ-1,stdin);
if(feof(stdin)) fatal("eof of input file!");
fputs(work,stdout);
lines++;
}
if((cmd->type & COM_ADD)==COM_ADD)
{
for(;;)
{
fgets(work,BUFSIZ-1,f);
if(*work=='.') break;
fputs(work,stdout);
fix_lines++;
}
}
if((cmd->type & COM_DEL)==COM_DEL)
{
while(lines<cmd->end)
{
fgets(work,BUFSIZ-1,stdin);
if(feof(stdin)) fatal("eof of input file");
lines++;
}
fix_lines -=(cmd->end-cmd->start);
}
lines += fix_lines;
}